package com.kevindubbo.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.kevindubbo.mapper.ItemMapper;
import com.kevindubbo.pojo.Item;
import com.kevindubbo.pojo.ItemExample;
import com.kevindubbo.pojo.ItemExample.Criteria;
import com.kevindubbo.service.ItemService;
/**
 * 
 * @author Kevin
 * @version 1.0
 * @since 2017/2/21
 *
 */
@Service
public class ItemServiceImpl implements ItemService {
	@Autowired
	private ItemMapper itemMapper;

	@Override
	public Item getItemById(long ItemId) {
		//根据条件查询
		ItemExample example = new ItemExample();
		//设置条件
		Criteria criteria = example.createCriteria();
		criteria.andIdEqualTo(ItemId);
		List<Item>list = itemMapper.selectByExample(example);
		if (list != null&&list.size() > 0) {
			Item item = list.get(0);
			return item;
		}
		return null;

	}
	

	@Override
	public List<Item> getItemList(Integer page, Integer rows) {
		//查询商品列表
		//分页处理
		PageHelper.startPage(page, rows);
		//执行查询
		ItemExample example = new ItemExample();
		List<Item> list = itemMapper.selectByExample(example);
		return list;
	}

}
